home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / mawk.zip / TYPES.H < prev    next >
C/C++ Source or Header  |  1991-04-07  |  3KB  |  113 lines

  1.  
  2. /********************************************
  3. types.h
  4. copyright 1991, Michael D. Brennan
  5.  
  6. This is a source file for mawk, an implementation of
  7. the Awk programming language as defined in
  8. Aho, Kernighan and Weinberger, The AWK Programming Language,
  9. Addison-Wesley, 1988.
  10.  
  11. See the accompaning file, LIMITATIONS, for restrictions
  12. regarding modification and redistribution of this
  13. program in source or binary form.
  14. ********************************************/
  15.  
  16.  
  17. /* $Log:    types.h,v $
  18.  * Revision 2.1  91/04/08  08:24:15  brennan
  19.  * VERSION 0.97
  20.  * 
  21. */
  22.  
  23.  
  24. /*  types.h  */
  25.  
  26. #ifndef  TYPES_H
  27. #define  TYPES_H
  28.  
  29. #if     HAVE_VOID_PTR
  30. typedef  void *PTR ;
  31. #else
  32. typedef  char *PTR ;
  33. #endif
  34.  
  35. #include  "sizes.h"
  36.  
  37.  
  38. /*  CELL  types  */
  39.  
  40. #define  C_NOINIT                0
  41. #define  C_DOUBLE                1
  42. #define  C_STRING                2
  43. #define  C_STRNUM                3
  44. #define  C_MBSTRN                4 
  45.         /*could be STRNUM, has not been checked */
  46. #define  C_RE                    5
  47. #define  C_SPACE                 6
  48.         /* split on space */
  49. #define  C_SNULL                 7
  50.         /* split on the empty string  */
  51. #define  C_REPL                  8
  52.         /* a replacement string   '\&' changed to &  */
  53. #define  C_REPLV                 9
  54.         /* a vector replacement -- broken on &  */
  55. #define  NUM_CELL_TYPES         10
  56.  
  57. /* these defines are used to check types for two
  58.    CELLs which are adjacent in memory */
  59.  
  60. #define  TWO_NOINITS  (2*(1<<C_NOINIT))
  61. #define  TWO_DOUBLES  (2*(1<<C_DOUBLE))
  62. #define  TWO_STRINGS  (2*(1<<C_STRING))
  63. #define  TWO_STRNUMS  (2*(1<<C_STRNUM))
  64. #define  TWO_MBSTRNS  (2*(1<<C_MBSTRN))
  65. #define  NOINIT_AND_DOUBLE  ((1<<C_NOINIT)+(1<<C_DOUBLE))
  66. #define  NOINIT_AND_STRING  ((1<<C_NOINIT)+(1<<C_STRING))
  67. #define  NOINIT_AND_STRNUM  ((1<<C_NOINIT)+(1<<C_STRNUM))
  68. #define  DOUBLE_AND_STRING  ((1<<C_DOUBLE)+(1<<C_STRING))
  69. #define  DOUBLE_AND_STRNUM  ((1<<C_STRNUM)+(1<<C_DOUBLE))
  70. #define  STRING_AND_STRNUM  ((1<<C_STRING)+(1<<C_STRNUM))
  71. #define  NOINIT_AND_MBSTRN  ((1<<C_NOINIT)+(1<<C_MBSTRN))
  72. #define  DOUBLE_AND_MBSTRN  ((1<<C_DOUBLE)+(1<<C_MBSTRN))
  73. #define  STRING_AND_MBSTRN  ((1<<C_STRING)+(1<<C_MBSTRN))
  74. #define  STRNUM_AND_MBSTRN  ((1<<C_STRNUM)+(1<<C_MBSTRN))
  75.  
  76. typedef  struct {
  77. unsigned short ref_cnt ;
  78. unsigned short len ;
  79. char str[4] ;
  80. } STRING ;
  81.  
  82.  
  83. typedef  struct cell {
  84. short type ;
  85. short vcnt ; /* only used if type == C_REPLV   */
  86. PTR   ptr ;
  87. double  dval ;
  88. }  CELL ;
  89.  
  90.  
  91. /* all builtins are passed the evaluation stack pointer and
  92.    return its new value, here is the type */
  93.  
  94. #ifdef __STDC__
  95. typedef CELL *(*PF_CP)(CELL *) ;
  96. #else
  97. typedef CELL *(*PF_CP)() ;
  98. #endif
  99.  
  100. /* an element of code (instruction) */
  101. typedef  union {
  102. int  op ;
  103. PTR  ptr ;
  104. }  INST ;
  105.  
  106. /* a scratch buffer type */
  107. union tbuff {
  108. PTR   ptr_buff[MAX_FIELD] ;
  109. char   string_buff[TEMP_BUFF_SZ + BUFFSZ + 1] ;
  110. } ;
  111.  
  112. #endif
  113.